import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';

dayjs.extend(utc);
dayjs.extend(timezone);

export function formatDate(date) {
    return dayjs(date).tz(dayjs.tz.guess()).format('YYYY-MM-DD HH:mm:ss');
}
export function formatDate1(date) {
    return dayjs(date).tz(dayjs.tz.guess()).format('YYYY-MM-DDTHH:mm:ssZ');
}
export function formatDuration(seconds: number) {
    seconds += 1800

    const days = Math.floor(seconds / (24 * 3600));
    seconds %= 24 * 3600;
    const hours = Math.floor(seconds / 3600);

    return `${days} 天 ${hours} 小时`;
}